package bsh.exception;

/**
 * Excecao para indicar erro durante a compilacao do script
 * 
 * @author takeshi
 */
public class CompilationFailedException extends Exception {

    /**
	 * 
	 */
    private static final long serialVersionUID = 1L;

    private final int lineNumber;

    /**
     * @param line int
     * @param message String
     */
    public CompilationFailedException(int line, String message) {
        super(message);
        this.lineNumber = line;
    }

    /**
     * @param line int
     * @param message String
     * @param cause cause
     */
    public CompilationFailedException(int line, String message, Throwable cause) {
        super(message, cause);
        this.lineNumber = line;
    }

    /**
     * @return int
     */
    public int getLineNumber() {
        return this.lineNumber;
    }

    /**
     * {@inheritDoc}
     * 
     * @see java.lang.Throwable#toString()
     */
    @Override
    public String toString() {
        return String.format("[%d] %s", this.lineNumber, this.getMessage());
    }

}
